<template>
  <div class="goodsindex">
    <!-- 搜索条件 -->
    <el-row :gutter="20" class="goodsindex-queryInfo">
      <!-- 商品名称搜索 -->
      <el-col :xs="8" :sm="6" :md="6" :lg="4" :xl="4">
        <el-input
          class="goodsindex-queryInfo-li"
          v-model="queryInfo.goodsName"
          clearable
          size="small"
          placeholder="请输入产品名称"
        ></el-input>
      </el-col>
     
      <el-col :xs="6" :sm="4" :md="3" :lg="2" :xl="2">
        <el-button
          type="primary"
          class="goodsindex-queryInfo-li"
          size="small"
          @click="initData"
          >搜索</el-button
        >
      </el-col>
    </el-row>
    <!-- 检索结果 -->
    <el-row :gutter="20" class="goodsindex-list">
      <el-col :span="24">
        <el-table
          :data="tableData.records"
          border
          size="small"
          style="width: 100%"
        >
          <el-table-column type="index" label="序" width="50">
          </el-table-column>
          <el-table-column prop="goodsName" label="产品名称" width="180">
          </el-table-column>

          <el-table-column prop="storeName" label="收货店铺" width="180">
          </el-table-column>

          <el-table-column prop="costPrice" label="成本价" width="100">
          </el-table-column>

          <el-table-column prop="inStockNum" label="出货数量" width="100">
          </el-table-column>

          <el-table-column prop="stockNum" label="收货店铺原有库存" width="180">
          </el-table-column>

          <el-table-column prop="createTime"  :formatter="dateFormat" label="出库时间" width="180">
          </el-table-column>
                 
                
        </el-table>
      </el-col>
    </el-row>
    <!-- 分页 -->
    <el-row :gutter="20" class="goodsindex-list">
      <el-col :span="24" class="goodsindex-page-box">
        <el-pagination
          :hide-on-single-page="true"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="queryInfo.page"
          :page-sizes="[5, 10, 20, 50]"
          :page-size="queryInfo.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableData.total"
        >
        </el-pagination>
      </el-col>
    </el-row>

  </div>
</template>

<script>
import moment from "moment";
export default {
  data() {
    return {
      queryInfo: {
        goodsName: "",
        goodsType: "",
        page: 1,
        pageSize: 5,
      },
      tableData: [],
    };
  },
  async created() {
    this.initData();
  },
  computed: {},
  filters: {},
  methods: {
    async initData() {
      let query = {
        ...this.queryInfo,
      };
      if (query.goodsName == "") delete query.goodsName;
      if (query.goodsType == "") delete query.goodsType;
      delete query.pageSize;
      delete query.page;
      let list = await this.http.post("/goodsStock/queryStockPage", {
        pageSize: this.queryInfo.pageSize,
        pageNo: this.queryInfo.pageNo,
        query: query,
      });
      this.tableData = list.result;
    },
    handleSizeChange(size) {
      this.queryInfo.pageSize = size;
      this.initData();
    },
    handleCurrentChange(currentPage) {
      this.queryInfo.pageNo = currentPage;
      this.initData();
    },

    to(url) {
      this.$router.push({ path: url });
    },
     
    SellType(row) {
      switch (row.goodsSellType) {
        case 1:
          return "艾家服务";
          break;
        case 2:
          return "一周严选";
          break;
        case 3:
          return "品牌推荐";
          break;
        default:
          return "默认";
          break;
      }
    },
    dateFormat(row, column) {
      let date = row[column.property];
      if (date == undefined) {
        return "";
      }
      return moment(date).format("YYYY-MM-DD HH:mm:ss");
    },
  },
};
</script>

<style scoped>
.goodsindex {
  width: 100%;
  min-height: 100%;
  padding: 15px;
  box-sizing: border-box;
}
/* 搜索 */
.goodsindex-queryInfo {
  margin-bottom: 10px;
}
.goodsindex-queryInfo-li {
  width: 100%;
  height: auto;
}
/* 列表 */
.goodsindex-list {
  width: 100%;
  height: auto;
  margin-bottom: 20px;
}
/* 分页 */
.goodsindex-page-box {
  width: 100%;
  height: auto;
  display: flex;
  justify-content: flex-end;
}
</style>